﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BrightIdeasSoftware;
using Managistics.Utility.Common.View.NNGrid.Datas;
using Managistics.Utility.Common.View.NNGrid.Columns;

namespace Managistics.Utility.Common.View.NNGrid.Controls
{
    public class NNComboBox : ComboBox
    {
        private object sender;
        private CellEditEventArgs cell;

        public NNComboBox()
        {
            
        }

        public NNComboBox(object sender, CellEditEventArgs cell)
        {
            this.Sender = sender;
            this.Cell = cell;
        }

        public object Sender
        {
            get { return sender; }
            set { this.sender = value; }
        }

        public CellEditEventArgs Cell
        {
            get { return cell; }
            set { cell = value; }
        }

        public void Initialize()
        {
            NNControlRender dataRender = ((NNGridColumn)(this.Cell.Column)).ControlRender;
            this.DataSource = dataRender.DataSource;
            this.ValueMember = dataRender.Value.ToString();
            this.DisplayMember = dataRender.Display.ToString();
            this.Text = dataRender.Value.ToString();
        }

        public object DataResponse()
        {
            ComboBox cbb = (ComboBox)this.Cell.Control;
            return cbb.SelectedItem;
        }
    }
}
